$('input').focus(function(){
	this.select();
});

$('.submitBtn').click(function(){
	var $username = $('.username').val();
	var $password = $('.password').val();
	var $remindBox = $('#remindBox');

	if($username == '' && $password == ''){
		$remindBox.css('display','block');
		$remindBox.text('请输入用户名和密码');
		setTimeout(function(){
			$remindBox.css('display','none');
		},1500)
	}else if($username == ''){
		$remindBox.css('display','block');
		$remindBox.text('请输入用户名');
		setTimeout(function(){
			$remindBox.css('display','none');
		},1500)
	}else if($password == ''){
		$remindBox.css('display','block');
		$remindBox.text('请输入密码');
		setTimeout(function(){
			$remindBox.css('display','none');
		},1500)
	}


	$.ajax({
		type : 'POST',
		url : "/api/v1/login",
		data : {
			paramStr: "{'userName':'" + $username + "','deviceType':'h5','password':'" + $password + "'}"
		},
		dataType : 'json',
		timeout : 10000,
		success : function (data) {
			if(data.code == 200){
				$('.submitBtn').attr('disabled',true).css('background','#ccc');
				var obj = eval('(' + data.data + ')');
				console.log(obj);
				sessionStorage.userName = obj.userInfo.userName;
				sessionStorage.token = obj.token;
				sessionStorage.ip = obj.userInfo.ip;
				sessionStorage.headImg = obj.userInfo.headImg;
				sessionStorage.m = obj.userInfo.mobile;
				sessionStorage.isVerify = obj.userInfo.isVerify;
				
				setTimeout(function(){
					window.location.href = "../index1.html";
				},1500);
			}
			$remindBox.css('display','block').text(data.message);
			setTimeout(function(){
				$remindBox.css('display','none');
			},1500);
		},
		error : function (xhr , type , errorThrown) {
			alert('未知错误');
		}
	});
});